import { configureStore } from "@reduxjs/toolkit";

import { loginApi } from "./request/loginrequest";

import loginslice from "./slice/loginslice";
import tabSlice from "./slice/tabslice";


import { registerApi } from "./request/registerrequest";
import { accountApi } from "./request/accountrequest";

import { dmprojectsApi } from "./request/datamonitorrequests/dmprojectsrequest";
import { publicPropsApi } from "./request/datamonitorrequests/publicpropsrequest";
import { beginMonitorApi } from "./request/datamonitorrequests/beginmonitorrequest";
import { systemversionApi } from "./request/systemversionrequest";
import { quartzApi } from "./request/datamonitorrequests/quartzrequest";
import watchstateSlice from "./slice/watchstateslice";
import { totalMileagesApi } from "./request/datamonitorrequests/totalmileagesrequest";
import { totalGPSApi } from "./request/datamonitorrequests/totalgpsrequest";

const store = configureStore({
    reducer: {
        //属性名需要中括号
        [loginApi.reducerPath]: loginApi.reducer,
        [registerApi.reducerPath]: registerApi.reducer,
        [accountApi.reducerPath]: accountApi.reducer,
        [publicPropsApi.reducerPath]: publicPropsApi.reducer,
        [beginMonitorApi.reducerPath]: beginMonitorApi.reducer,
        [systemversionApi.reducerPath]: systemversionApi.reducer,
        [quartzApi.reducerPath]:quartzApi.reducer,
        [dmprojectsApi.reducerPath]: dmprojectsApi.reducer,
        [totalMileagesApi.reducerPath]:totalMileagesApi.reducer,
        [totalGPSApi.reducerPath]:totalGPSApi.reducer,

        //loginpara这个名称是给组件调用useSelector（state=>{state.loginpara}）时使用
        loginpara: loginslice.reducer,
        tabpara: tabSlice.reducer,
        watchstatepara: watchstateSlice.reducer

    },
    middleware: getDefaultMiddleware =>
        getDefaultMiddleware({

        }).concat(loginApi.middleware).concat(registerApi.middleware)
            .concat(accountApi.middleware).concat(publicPropsApi.middleware)
            .concat(dmprojectsApi.middleware).concat(beginMonitorApi.middleware)
            .concat(systemversionApi.middleware).concat(quartzApi.middleware)
            .concat(totalMileagesApi.middleware).concat(totalGPSApi.middleware),
});
//store 只能默认导出
export default store;